<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>  
    <!DOCTYPE html>
    <html>
    <head>
     <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
     <link rel="stylesheet" type="text/css" href="style/other/easyui.css">
    <link rel="stylesheet" type="text/css" href="style/other/icon.css">
    <link rel="stylesheet" type="text/css" href="style/other/demo.css">
    <script type="text/javascript" src="style/js/jquery-1.8.1.min.js"></script>
    <script type="text/javascript" src="style/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="style/js/my.js"></script>
    </head>
    <body onload="">
    
    
    <div class="easyui-layout" fit="true" style="height:200px;">
    	<div data-options="region:'east',split:true" title="监控台" style="width:300px;">
			<ul class="easyui-tree" id="statslogin"></ul>
		</div>
		
		
		
		
		<div id="content" region="center" title="扫码登录" style="padding:20px;">
		
		
		请选择分局:<select name="province" id="province" onchange="two_menu(value)">
		</select>
		派出所:<select name="city" id="city" onchange="view_Login(value)">
		<option>--请选择派出所--</option>
		</select>
		
		<div align="center" id="title" >
		 <h1  >成功登录</h1>
		 </div>
    	<div align="center" id="uuid" >
    	
         
    	<img id="loginImg" name="loginImg" src="https://login.weixin.qq.com/qrcode/${uuid}">
   
    
 <p align="center">点击图片刷新</p>
 <p id="resultLogin" align="center"></p>
    </div>

    	</div>
    	
    	
    	</div>

    	<script>
      
    		$(function(){
    			$("#uuid").hide();
    			$("#title").hide();
    			one_menu();
    			
  				var datas = '';
  				
            	 function runajax(){
            		
         			$.ajax({
         				url:"<%=basePath%>admin/user_getResults.action",
         				datatype:"json",
         				type:"post",
         				async:"true",
         			}).success(function(data){
         				 console.log(data);
         				if(datas!=data){
         				if(data.split(":")[0]=="已经扫描成功，等待确认登陆"){
         					
         					$("#resultLogin").html("已经扫描成功，等待确认登陆");
         				}
         				if(data.split(":")[0]=="开始心跳"){
         					$("#resultLogin").html("开始心跳");
         					$("#uuid").hide();
         					$("#resultLogin").html();
         					$("#title").show();
         				}
         				if(data.split(":")[1]=='0'){
         				$("#statslogin").html($("#statslogin").html()+"<li>"+data+"<li>");
         				}else if(data.split(":")[1]=='1101'){
         					$("#statslogin").html($("#statslogin").html()+"<li>"+data+"已下线<li>");
         				}
         			}
         				datas = data;
         			}).error();
         		}
         		
         		setInterval(runajax,1000);
         		
         		function getImgUuid(){
         			$.ajax({
         				url:"<%=basePath%>admin/user_getReUuid.action",
         				datatype:"json",
         				type:"post",
         				async:"true",
         			}).success(function(data){
         				$("#loginImg").attr("src","https://login.weixin.qq.com/qrcode/"+data);
         			}).error(function(data){
         			});
         		}
         		
         		$("#loginImg").click(function(){
         			$.ajax({
         				url:"<%=basePath%>admin/user_getReUuid.action",
         				datatype:"json",
         				type:"post",
         				async:"true",
         			}).success(function(data){
         				$("#loginImg").attr("src","https://login.weixin.qq.com/qrcode/"+data);
         			}).error(function(data){
         			});
         		});
         		
         		//setInterval(getImgUuid,245000);
         		
         		
         		
         		
         		 function one_menu(){
         			
          			$.ajax({
          				url:"<%=basePath%>admin/menu_oneMenu.action",
          				datatype:"json",
          				type:"post",
          				async:"true",
          			}).success(function(data){
          			
          				 var json = eval($.parseJSON(data)); //数组
          			
          				document.getElementById("province").options[0]= new Option("--请选择分局--","--请选择分局--");
          			
          				 for(var i = 0;i<json.length;i++){
          				
          					document.getElementById("province").options[i+1]=new Option(json[i].sub_name,json[i].sub_id);
	
          				}
          				 
          				
          				
          			}).error();
          		}
          		
         		 
         		
    		});
    		
    		function two_menu(value){
    			
       			$.ajax({
       				url:"<%=basePath%>admin/menu_twoMenu.action",
       				datatype:"json",
       				type:"post",
       				async:"true",
       				data:{"polMenu.sub_id":value}
       			}).success(function(data){
       				
       				var json = eval($.parseJSON(data)); //数组
   				document.getElementById("province").options[0]= new Option("--请选择派出所--","--请选择派出所--");
   				for(var i = 0;i<json.length;i++){
  					
  					document.getElementById("city").options[i+1]=new Option(json[i].pol_name,json[i].pol_id);

  				}	
   					

       			}).error();
       		}

    		function view_Login(value){
    		
       			$.ajax({
       				url:"<%=path%>/admin/user_getHttpUserList.action",
       				datatype:"json",
       				type:"post",
       				async:"true",
       				data:{"polMenu.pol_id":value}
       			}).success(function(data){
       				$("#uuid").show();
       				$("#loginImg").attr("src","https://login.weixin.qq.com/qrcode/"+data);
   				

       			}).error();
       		}	
    	</script>
    </body>
    </html>